package com.bjfu.demo.controller;

import com.bjfu.demo.task.NewStoreSiteDetailTask;
import com.bjfu.demo.utils.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class FlushDataController {
    @Resource
    private NewStoreSiteDetailTask newStoreSiteDetailTask;

    @GetMapping("/flush/{key}")
    public Result flush(@PathVariable String key) {
        if (!"bjfu1022".equals(key)){
            return Result.ok("参数不正确");
        }
        newStoreSiteDetailTask.storeStationInfo();
        newStoreSiteDetailTask.storeStatisticResultByYear();
        newStoreSiteDetailTask.storeStatisticResultBySeason();
        newStoreSiteDetailTask.storeStatisticResultByMonth();
        return Result.ok("redis初始化成功");
    }
}
